<?php
include_once("../dao/permissoes_dao_class.php");
include_once("../model/permissoes_model_class.php");

//use dao\PermissoesDAO as PerDao;
//use model\PermissoesModel as PerModel;

class PermissoesController{
    
    function cadastrar($nivel, $opcoes){
        
        $per = new PermissoesDAO();
        
        $per->delete($nivel);
        
        $perM = new PermissoesModel();
        $perM->setNivel($nivel);
        $perM->setOpcoes($opcoes);
            
        

        return $per->insert($perM);
        
        
         
    }
    
//    function alterar($id, $nivel, $opcoes){
//        
//        $perM = new PermissoesModel();
//        $perM->setNivel($nivel);
//        $perM->setOpcoes($opcoes);
//            
//        $per = new PermissoesDAO();
//        
//        return $per->update($perM);
//    }
    
    function excluir($id){
        
        $per = new PermissoesDAO();
        
        return $per->delete($id);
    }
    
    function selecionar(){
        $per = new PermissoesDAO();
        
        return $per->findAllPermissoes();
    }
    
    function selecionarPorNivel($nivel){
        $per = new PermissoesDAO();
        
        return $per->findByNivel($nivel);
    }
    
}

//$teste = new PermissoesController();
//
//echo $teste->excluir(8);

